package com.home.rest;/**
 * @author chenxf
 * @date 2022/4/22 14:02
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.home.base.msg.TableResultResponse;
import com.home.base.rest.BaseRestController;
import com.home.biz.PolicyNewsInfoBiz;
import com.home.entity.PolicyNewsInfo;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chenxf
 * @date 2022/4/22 14:02
 */
@RestController
@RequestMapping("/api/policy/news")
public class PolicyNewsInfoControllerApi extends BaseRestController<PolicyNewsInfoBiz, PolicyNewsInfo> {
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public TableResultResponse<PolicyNewsInfo> list(
            @RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,String orderStr) {
        List<PolicyNewsInfo> items = baseBiz.list(limit,offset,orderStr);
        PageInfo<PolicyNewsInfo> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())), offset, limit,
                items);
    }
}
